import { AfterViewInit } from '@angular/core';
import { Component, ElementRef, Input,  ViewChild } from '@angular/core';

declare var katex: any;

@Component({
  selector: 'katex-block',
  templateUrl: './katex-block.component.html',
  styleUrls: ['./katex-block.component.scss']
})
export class KatexBlockComponent implements AfterViewInit  {

  constructor() { }

  @ViewChild("tref", {read: ElementRef}) tref!: ElementRef;
  @Input() value!:string;
  @Input() edit:boolean = false;

  ngAfterViewInit(): void {    
    katex.render(this.value, this.tref.nativeElement, { displayMode: true });
  }
}
